<template>
    <div>
     <table>
        <tbody>
            <tr>
                <td>门店名称</td>
                <td><input type="text" v-model="data.userName"></td>
            </tr>
            <tr>
                <td>营业时间</td>
                <td>
                    <input type="text" v-model="data.userTime">至<input type="text" v-model="data.userTimes">
                </td>
            </tr>
            <tr>
                <td>客服电话</td>
                <td><input type="text" v-model="data.userPhone"></td>
            </tr>
            <tr>
                <td>地址</td>
                <td><input type="text" v-model="data.userAddress"></td>
            </tr>
            <tr>
                <td>门店状态</td>
                <td>
                    <select v-model="data.hoteId">
                        <option value="0">请选择</option>
                        <option v-for="a in datas":value="a.hoteId">{{a.hoteName}}</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>图片</td>
                <td>
                    <input type="file" @change="upfile">
                    <img :src="'https://localhost:7186/' + data.userImg" style="width: 60px;height: 60px;">
                </td>
            </tr>
             <tr>
                <td></td>
                <td><input type="button" value="修改" @click=""></td>
            </tr>
        </tbody>
     </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { useRoute } from 'vue-router';
const route=useRoute()

const router = useRouter();


onMounted(()=>{
    xiala()
    getfan()
})

const datas = ref([ {
    "hoteId": 0,
    "hoteName": "string"
  }])

const xiala=()=>{
    axios.get("/api/Hote/Show").then(res=>{
    datas.value = res.data
    })
}

const data = ref({
  "userId": 0,
  "hoteId": 0,
  "userName": "string",
  "userTime": "string",
  "userTimes": "string",
  "userPhone": "string",
  "userAddress": "string",
  "userShan": true,
  "delTime": "2025-06-05T13:06:46.034Z",
  "upTime": "2025-06-05T13:06:46.034Z",
  "userImg": "string"
})

const upfile=(val:any)=>{
  var f = val.target.files[0];
  var fd = new FormData();
  fd.append("file",f)
    

   if(f.size>2*1024*1024){
   alert("大小不能超过2MB");
   return;
   }

  axios.post("/api/User/PostImg",fd).then(res=>{
  data.value.userImg = res.data
  })
}

const getfan=()=>{
    
    const mid=route.query.id

    axios.get("/api/User/GetFan",{params:{id:mid}}).then(res=>{
    data.value = res.data
    })
}
</script>

<style scoped>

</style>